home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGNG_C / CUTILV1.LZH / C86MOD.DOC next >
Text File  |  1984-07-29  |  3KB  |  65 lines

  1. Author:
  2. -------
  3.    Michael Evans   (312) 329-6302 days.
  4.  
  5. Summary:
  6. --------
  7.       The following patch to any EXE type file created by the C86 linker (cl)
  8.    will allow the return code from function MAIN to be passed to DOS 2.0.
  9.    Once applied, the ERRORLEVEL batch facility in DOS 2.0 may be used
  10.    to evaluate the returned value from a C86 program.  One handy implementation
  11.    is patching the EXE files provided with the C86 system so that a batch file
  12.    can test for successful completion of the various C86 programs.
  13.  
  14.        Restrictions: a. DOS 2.0 only allows for an 8 bit return code, thus the
  15.                         16 bit result from C86 will be folded via OR to 8 bits.
  16.                      b. Once patch is applied, modules are not downward
  17.                         compatible from DOS 2.0.
  18.  
  19.               Notes: a. ALL values mentioned below are HEXADECIMAL.
  20.                      b. When looking at a word in storage, remember that it
  21.                         is stored LEAST significant byte first.
  22.                      c. ALWAYS assume SIGNED quantities unless otherwise noted.
  23.                      d. This patch was tested on software supplied as
  24.                         version 1.33D from CI.
  25.                      e. NEVER alter the original CI release diskettes.
  26.                      f. Abort the procedure if any verifications do not match,
  27.                         the patch will only work if installed exactly as shown.
  28.  
  29. Procedure:
  30. ----------
  31.  
  32.    1. Copy filename with EXE extension to one with a ZAP extension.
  33.  
  34.    2. Load the filename.ZAP file under DEBUG.
  35.  
  36.    3. Locate the program entry point as follows:
  37.       a. At offset 108 in the file is a word containing the header size
  38.          in paragraphs, multiply this value by 10.
  39.       b. Perform an addition of the words at file offsets 114 and
  40.          116.
  41.       c. The entry point of the program is 100 + (step 3.a) + (step 3.b).
  42.  
  43.    4. The byte at location (step 3.c) must be an E9, if not, recheck the
  44.       preceding steps.
  45.  
  46.    5. The file offset to $MAIN is: 3 + (step 3.c) + the contents of the word
  47.       at file offset ((step 3.c) + 1).
  48.  
  49.    6. Locate the following string within 8 bytes of (step 5) + 58:
  50.       8A 1E nn nn 0A DB 74 35 78 04  (nn means don't care).
  51.  
  52.    7. Considering the file offset of the string in step 6 as BASE, make the
  53.       following modifications:
  54.       a. Move 2 bytes from BASE + 2 to BASE + 4.
  55.       b. Change bytes starting at BASE to: 0A C4 D0 26
  56.       c. Change bytes starting at BASE + 6 to: 72 06 74 31
  57.       d. Verify at BASE + D: 2F, change to: 2D
  58.       e. Verify at BASE + 35: 76 05 8B 6E 00 EB D3 58,
  59.                    change to: 8B 6E 00 77 D5 58 B4 4C
  60.       f. Verify at BASE + 3E: 20, change to: 21
  61.  
  62.    8. Update filename.ZAP with W subcommand of DEBUG, then exit via Q.
  63.  
  64.    9. Rename filename.ZAP to filename.EXE.
  65.